Run this from the stat436_notes root directory to compile all course notes.
# Remove any existing HTML files in post directories
unlink(list.files("_posts", pattern = "*.html", recursive = TRUE, full.names = TRUE))
# Clear cache directories
system("find _posts -type d -name '*cache*' -exec rm -rf {} +")
system("find _posts -type d -name '*files*' -exec rm -rf {} +")
library(tidyverse)
library(rmarkdown)
library(distill)
# Find all .Rmd files in _posts subdirectories
files <- list.files(path = "_posts", pattern = "*.Rmd", recursive = TRUE, full.names = TRUE)
# Exclude the compile script itself
files <- setdiff(files, c("_posts/compile.Rmd"))
# Render each individual post
cat("Found", length(files), "files to render:\n")
for (i in seq_along(files)) {
cat("Rendering", i, "of", length(files), ":", files[i], "\n")
tryCatch({
render(files[i])
}, error = function(e) {
cat("Error rendering", files[i], ":", e$message, "\n")
})
}
# Now render the complete site
render_site()
To use this script:
docs/ directory for the compiled siteThe script will: - Clean up any previous builds - Render each individual course note - Compile the main site with proper navigation